<?php

//js для редактирования формы
$this->headScript()->appendFile("/js/admin/form.js");

?>

<script type="text/javascript">

$(document).ready(function() {

    var constr = new $.formConstructor();

    //кнопка добавления нового поля
	$("#<?= $this->form->getId() ?> a[rel=multiple]").live('hover', function() {
        $(this).toggleClass('ui-state-hover');
    }).live('click', function() {
		constr.cloneField(this);
		return false;
	});
    
    $("#<?= $this->form->getId() ?> a[rel=delete]").live('hover', function() {
		$(this).toggleClass('ui-state-hover');
    }).live('click', function() {
		var res = confirm("Удалить значение?");
		if (res) {
            var testHref = this.href.replace(location.href, "");
            if (!testHref || testHref == '#') {
				constr.removeField(this);
            } else {
                var cur = this;
                $.ajax({
                    url: this.href,
                    cache: false,
                    success: function() { $.formConstructor.removeField(cur) },
                    error: function() { $.formConstructor.error(cur) }
                });
            }
		}
		return false;
	});
});

</script>
<div class="form" id="page_form">
    <?= $this->form ?>
    <br/>
</div>